﻿using System.Collections.Specialized;

using Kwan.Data;
using BG.Data;

namespace BG.Service
{
    public class ModuleQuery
	{

		public static Expression MakeSearchWhere(NameValueCollection ps)
		{
			Expression exp = new Expression();

            string propName = "EntityID";
            if (!string.IsNullOrEmpty(ps[propName]))
                exp &= TModule.entityID == ps[propName];

			propName = "nameCN";
			if (!string.IsNullOrEmpty(ps[propName]))
			{
                exp &= TModule.nameCN == ps[propName];
			}
			propName = "nameEN";
			if (!string.IsNullOrEmpty(ps[propName]))
			{
                exp &= TModule.nameEN == ps[propName];
			}
			propName = "pid";
			if (!string.IsNullOrEmpty(ps[propName]))
			{
                exp &= TModule.pid == ps[propName];
			}
			propName = "status";
			if (!string.IsNullOrEmpty(ps[propName]))
			{
                exp &= TModule.status == bool.Parse(ps[propName]);
			}

			return exp;
		}
	}
}